/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.projektjava;

import java.sql.DriverManager;
import java.util.Calendar;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import junit.framework.TestCase;

/**
 *
 * @author Ondřej Myška
 */
public class ReservationDAOImplTest extends TestCase {
    /*
     private EntityManagerFactory emf;
    private EntityManager em;
    */
    public ReservationDAOImplTest(String testName) {
        super(testName);
        
    }
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        /*
        try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;create=true").close();
        } catch (Exception ex) {
            System.err.println("problem pri inicializaci");
        }
        emf = Persistence.createEntityManagerFactory("TestPU");
        em = emf.createEntityManager();
        
        */
    }
    
    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
      /*   // zavření zdrojů
        if (em != null) {
            em.close();
        }
        if (emf != null) {
            emf.close();
        }
        // zruseni in memory db
        try {
            DriverManager.getConnection("jdbc:derby:memory:unit-testing-jpa;shutdown=true").close();
        } catch (Exception ex) {
            System.err.println("problem pri ruseni db");
        }
*/
 }
    
    private Car createCar(){
        Car c = new Car();
        c.setId("2J6");
        c.setAvailable(1);
        c.setColour("Cervena");
        c.setNumberOfSeats(4);
        c.setType("combi");
        return c;
        
    }
    
    private Employee createEmployee(){
        Employee e = new Employee();
        e.setId(Long.MIN_VALUE);
        e.setName("jmeno");
        e.setSurname("prijmeni");
        //e.setBirthDate(new Calendar());
        return e;
    }

    /**
     * Test of create method, of class ReservationDAOImpl.
     */
    public void testCreate() {
        System.out.println("create");
        Reservation r = new Reservation();
        r.setCar(createCar());
        r.setEmployee(createEmployee());
        r.setId(2L);
        ReservationDAOImpl impl = new ReservationDAOImpl();
        impl.create(r);
        assertEquals(impl.getByID(2L),r);
        
    }

    /**
     * Test of update method, of class ReservationDAOImpl.
     */
    public void testUpdate() {
        /*System.out.println("update");
        Reservation reservation = new Reservation();
        ReservationDAOImpl instance = new ReservationDAOImpl();
        */
       
    }

    /**
     * Test of remove method, of class ReservationDAOImpl.
     */
    public void testRemove() {
        /*
        System.out.println("remove");
        Reservation reservation = null;
        ReservationDAOImpl instance = new ReservationDAOImpl();
        instance.remove(reservation);
        // TODO review the generated test code and remove the default call to fail.
        //fail("The test case is a prototype.");
        * */
    }

    /**
     * Test of getByID method, of class ReservationDAOImpl.
     */
    public void testGetByID() {
        /*
        System.out.println("getByID");
        Long id = null;
        ReservationDAOImpl instance = new ReservationDAOImpl();
        instance.getByID(id);
        // TODO review the generated test code and remove the default call to fail.
       // fail("The test case is a prototype.");
       * */
    }

    /**
     * Test of get method, of class ReservationDAOImpl.
     */
    public void testGet() {
        /*
        System.out.println("get");
        Employee employee = null;
        ReservationDAOImpl instance = new ReservationDAOImpl();
        List expResult = null;
        List result = instance.get(employee);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
       /// fail("The test case is a prototype.");
       * */
    }
}
